package com.gitee.liuzhi.common.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.FieldNameConstants;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author liuzhi
 * @Date 2023/8/27 21:12
 * @Version 1.0
 * @Description 员工实体类
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@FieldNameConstants         // 为所有字段生成一个以字段名称为值的常量
@Accessors(chain = true)    // 链式构造
@Builder                    // 建造者
@Slf4j                      // 日志打印
public class Employee {

    private String name;
    private String dept;
    private int salary;
    private List<Employee> subordinates;

    public Employee(String name, String dept, int sal) {
        this.name = name;
        this.dept = dept;
        this.salary = sal;
        subordinates = new ArrayList<>();
    }

    public void add(Employee e) {
        subordinates.add(e);
    }

    public void remove(Employee e) {
        subordinates.remove(e);
    }

}
